package org.ioc.com.springaop.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class MyAspectDemo {
    @Around("@annotation(org.ioc.com.springaop.config.MyAspect)")
    public Object doAround(ProceedingJoinPoint joinPoint){
        log.info("do Around before....");
        Object o=null;
        try {o=joinPoint.proceed();
        } catch (Throwable e) {
            log.error("出现异常");
        }
        log.info("do Around after....");
        return o;
    }
    @Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
    public Object doAround1(ProceedingJoinPoint joinPoint){
        log.info("do Around before....");
        Object o=null;
        try {o=joinPoint.proceed();
        } catch (Throwable e) {
            log.error("出现异常");
        }
        log.info("do Around after....");
        return o;
    }
}
